import java.util.*;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main3 {
    public static String[] s;
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        while (t-- != 0) {
            int n = in.nextInt();
            in.nextLine();
            //StringBuffer stringbuffer = new StringBuffer();
            s = new String[n];
            for (int i = 0; i < n; i++) {
                s[i] = in.nextLine();
                //stringbuffer.append(s.charAt(i));
            }
            if (select(n)) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
            // if(stringbuffer.equals(stringbuffer)) {
            //     System.out.println("Yes");
            // } else {
            //     System.out.println("No");
            // }
        }
    }

    public static boolean select(int n) {
        for (int i = 0; i < n / 2; i++) {
            int j = n - i - 1;
            for (int t1 = 0; t1 < s[i].length(); t1++) {
                char ch1 = s[i].charAt(t1);
                boolean flag = false;
                for (int t2 = 0; t2 < s[j].length(); t2++) {
                    char ch2 = s[j].charAt(t2);
                    if (ch1 == ch2) {
                        flag = true;
                        break;
                    }
                }
                if (!flag) {
                    return false;
                } else {
                    break;
                }
            }
        }
        return true;
    }
}